import os
import time
import logging


logger_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'log')
current_date = '{}{}{}'.format(time.localtime(time.time()).tm_year, time.localtime(time.time()).tm_mon, time.localtime(time.time()).tm_mday)


def make_logger(name):
    handler = logging.FileHandler(filename=os.path.join(logger_path, '{}_{}.log'.format(name, current_date)), encoding='utf8')
    fmt = logging.Formatter(
        fmt='%(asctime)s -- %(name)s -- %(module)s -- %(levelname)s -- %(message)s',
        datefmt='%Y-%m-%d %H:%M:%S'
    )
    handler.setFormatter(fmt=fmt)
    logger = logging.Logger(name='{}'.format(name), level=10)
    logger.addHandler(handler)
    return logger
